<?php
session_start();
include ("sqlconnection.php");
$db = new Database();
$db->connect();

$username = $_SESSION["username"];

$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$gender = $_POST['sex'];
$nationality = $_POST['nationality'];
$personality = $_POST['personality'];
$behaviour = $_POST['checkbox'];
$state = $_POST['state'];
$postal = $_POST['postalcode'];
$uni = $_POST['university'];
$program = $_POST['program'];



		
$query = "update usertable  set pid = $personality, nationality = '$nationality', firsttime = 0,gender = '$gender', ".	  
		  "firstname = '$firstname',".
		 " lastname = '$lastname',".
		 " program = '$program',".
		  "university = '$uni',".
		  "about_me = '',".
		  "state = '$state', postal = $postal where username = '$username'";
		  

$result = mysql_query($query);

if(mysql_affected_rows() > 0){

	
	for($i=0; $i < count($behaviour); $i++){
		$query = "insert into users_behaviour values ($behaviour[$i], '$username')";
		mysql_query($query);
	}
$db->disconnect();

header("Location: index.html");

}else{

}




?>